package com.base.pig.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;

import com.base.pig.dto.ScReportsManageDto;
import com.base.pig.service.ScReportsManageService;
import com.base.pig.util.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Map;

/**
 * @ProjectName intelligent-city
 * @Package com.pig4cloud.pig.lab.controller
 * @ClassName ReportsManage
 * @Description 报表管理控制类
 * @Company lab
 * @Author wangw
 * @Date 2020/6/24 0024 9:38
 * @UpdateUser
 * @UpdateDate
 * @UpdateRemark
 * @Version 1.0.0
 */
@RestController
@RequestMapping("/reportsManage")
public class ScReportsManageController {

    @Autowired
    private ScReportsManageService scReportsManageService;

    /**
     * @return
     * @Title 设备报警报表查询
     * @Description
     * @Param scReportsManageDto : 参数传输对象
     * @author wangw
     * @date 2020/6/24 0024 9:43
     */
    @RequestMapping(value = "/getDeviceAlarmReports", method = RequestMethod.GET)
    public R getDeviceAlarmReports(ScReportsManageDto scReportsManageDto) {
        List list = scReportsManageService.getDeviceAlarmReports(scReportsManageDto);
        return R.ok(list);
    }

    /**
     * @return
     * @Title 报表管理-导出EXCEL
     * @Description
     * @author wangw
     * @date 2020/6/28 0028 14:23
     */
    @RequestMapping(value = "/reportExport", method = RequestMethod.GET)
    @ResponseBody
    public void reportExport(HttpServletRequest request, HttpServletResponse response,ScReportsManageDto scReportsManageDto) {
        scReportsManageService.export(request,response,scReportsManageDto);
    }

    /**
     * @param scReportsManageDto : 参数传输对象
     * @return
     * @Title 设备年/月/日报表查询
     * @Description
     * @author wangw
     * @date 2020/6/24 0024 14:50
     */
    @RequestMapping(value = "/getReports", method = RequestMethod.GET)
    public R getReports(ScReportsManageDto scReportsManageDto) {
        IPage page = scReportsManageService.getReports(scReportsManageDto);
        return R.ok(page);
    }

    /** 
     * @Title 年月报表查看详情
     * @Description
     * @param scReportsManageDto : 参数传输对象
     * @return 
     * @author wangw
     * @date 2020/6/29 0029 13:31
    */
    @RequestMapping(value = "/getYearMonthReportsDetails", method = RequestMethod.GET)
    public R getYearMonthReportsDetails(ScReportsManageDto scReportsManageDto){
        Map map = scReportsManageService.getYearMonthReportsDetails(scReportsManageDto);
        return R.ok(map);
    }

    /**
     * @Title 日报表查看详情
     * @Description
     * @param scReportsManageDto : 参数传输对象
     * @return
     * @author wangw
     * @date 2020/6/29 0029 13:31
     */
    @RequestMapping(value = "/getDayReports", method = RequestMethod.GET)
    public R getDayReports(ScReportsManageDto scReportsManageDto){
        IPage iPage = scReportsManageService.getDayReports(scReportsManageDto);
        return R.ok(iPage);
    }
    
    /** 
     * @Title 日报表查询设备信息
     * @Description
     * @param scReportsManageDto : 参数传输对象
     * @return 
     * @author wangw
     * @date 2020/7/2 0002 16:45
    */
    @RequestMapping(value = "/getDayReportsDeviceInfo", method = RequestMethod.GET)
    public R getDayReportsDeviceInfo(ScReportsManageDto scReportsManageDto){
        Object obj = scReportsManageService.getDayReportsDeviceInfo(scReportsManageDto);
        return R.ok(obj);
    }
}